package HLLib.base;

import HLCode.HLClass;
import HLCode.HLClassManager;
import HLCode.HLClassManager_H;
import HLCode.HLLibObject;

public class HLLoading extends HLLibObject {
    public HLClass GetClass(HLClassManager classManager) {
        return classManager.GetLibClass(HLClassManager_H.CLASS_GROUP_TYPE_LIB_BASE, HLClassManager_H.LIB_CLASS_BASE_Loading);
    }

    static int curProgress;

    static boolean isLoading;

    public static void SetProgress(int progress) {
        if (!isLoading) {
            return;
        }
        int oldProgress = curProgress;
        curProgress = progress;
        if (curProgress > 100) {
            curProgress = 100;
        } else if (curProgress < 0) {
            curProgress = 0;
        }
        if (oldProgress != curProgress && curCanvas != null) {
            curCanvas.repaint();
            curCanvas.serviceRepaints();
        }
        if (curProgress >= 100) {
            isLoading = false;
        }
    }

    public static int GetProgress() {
        return curProgress;
    }

    public static void AddProgress(int progress) {
        SetProgress(curProgress + progress);
    }

    public static boolean IsLoading() {
        return isLoading;
    }

    public static void Start() {
        isLoading = true;
        curProgress = -1;
        SetProgress(0);
    }
}
